
********************************************************************************
* calculate additional variable costs of holding physical and electronic books 
*********************************************************************************


*********************************************************
** Load data and merge with income info 

use $datapath/clean/main_data.dta, clear 

merge m:1 fipsplac fipsst using "$datapath/clean/income_place_data.dta"
	drop if _merge==2
	drop _merge 

	
	label var Np "phys holdings"
	label var Ne "ebook holdings"

	egen sno=group(stabr)

	
*********************************************************
* holdings costs associated with staffing
	
eststo clear 

eststo: reghdfe staffexp Np Ne, absorb(nlib year)	



*********************************************************
** Robustness: adding more controls

eststo: reghdfe staffexp Np Ne, absorb(nlib year sno )	
eststo: reghdfe staffexp Np Ne medinc, absorb(nlib year sno )	

	label var staffexp "staffing costs"
	label var Np "print holdings"
	label var Ne "ebook holdings"
	label var medinc "median income"

	local pattern prefix(/multicolumn{@span}{c}{) suffix(}) span erepeat(/cmidrule(lr){@span})

	esttab,  noomitted mtitles("baseline" "state FE" "& med inc") drop( _cons) se replace  label nonotes star( * 0.10 ** 0.05 *** 0.01) scalars("r2_a $/overline{R^2}$")   nocons
*********************************************************
	
	
